//
//  PPAboutViewController.m
//  pickpic
//
//  Created by Jinxiao on 8/27/16.
//  Copyright © 2016 MicroDream. All rights reserved.
//

#import "PPAboutViewController.h"
#import "PPUserAgreementViewController.h"

@interface PPAboutViewController ()
@property (weak, nonatomic) IBOutlet UIView *topLine;
@property (weak, nonatomic) IBOutlet UIView *centerLine;
@property (weak, nonatomic) IBOutlet UIView *bottomLine;
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;

@end
@implementation PPAboutViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = WHITE;
    
    self.title = @"关于pickpic";
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithTitle:@"设置" image:@"nav_back" target:self action:@selector(popViewPreviousController)];
    
//    self.tableView.bounces = NO;
//    [_topLine addTopBorderWithColor:kLineColor andWidth:kLineWidth];
//    [_centerLine addBottomBorderWithColor:kLineColor andWidth:kLineWidth];
//    [_bottomLine addBottomBorderWithColor:kLineColor andWidth:kLineWidth];

//    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
//    _versionLabel.text = [NSString stringWithFormat:@"pickpic 版本 %@", version];
    
    
    
    UIImageView *logoView = [[UIImageView alloc] init];
    logoView.image = [UIImage imageNamed:@"logo-nav-black"];
    CGFloat logoW = logoView.image.size.width;
    CGFloat logoH = logoView.image.size.height;
    logoView.frame = CGRectMake(self.view.frame.size.width/2 - logoW/2,136,logoW, logoH);
    [self.view addSubview:logoView];

    UILabel *versionLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(logoView.frame)+33, self.view.frame.size.width, 21)];
    versionLabel.textAlignment = NSTextAlignmentCenter;
    versionLabel.font = PFFontBold(17);
    versionLabel.textColor = BLACK;
    versionLabel.text = [self appversion];
    [self.view addSubview:versionLabel];
    
    
    CGFloat w = self.view.frame.size.width;
    CGFloat h = self.view.frame.size.height;
    
    UILabel *copyRight = [[UILabel alloc] initWithFrame:CGRectMake(0,h - 100, w, 21)];
    copyRight.textAlignment = NSTextAlignmentCenter;
    copyRight.font = PPFONTSIZE(12);
    copyRight.textColor = COLORA(190, 190, 193);
    copyRight.text = @"copyright © 2017版权保护";
//    copyRight.backgroundColor = RED;
    [self.view addSubview:copyRight];
    
    
    UIButton *agreeMentBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CGFloat agreeW = 100;
    CGFloat agreeH = 35;
    agreeMentBtn.frame = CGRectMake(w/2 - agreeW/2,copyRight.frame.origin.y - 40,agreeW,agreeH);
    [agreeMentBtn setTitle:@"用户协议" forState:UIControlStateNormal];
    agreeMentBtn.titleLabel.font = PPFONTSIZE(14);
    [agreeMentBtn addTarget:self action:@selector(appAgreement) forControlEvents:UIControlEventTouchUpInside];
    [agreeMentBtn setTitleColor:BLACK forState:UIControlStateNormal];
    [self.view addSubview:agreeMentBtn];
    
    
    UIButton *gradeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    CGFloat gradeBtnW = 80;
    CGFloat gradeBtnH = 35;
    gradeBtn.frame = CGRectMake(w/2 - gradeBtnW/2,agreeMentBtn.frame.origin.y - 40,gradeBtnW,gradeBtnH);
    [gradeBtn setTitle:@"去评分" forState:UIControlStateNormal];
    [gradeBtn addTarget:self action:@selector(appgrade) forControlEvents:UIControlEventTouchUpInside];
    gradeBtn.titleLabel.font = PPFONTSIZE(14);
    [gradeBtn setTitleColor:BLACK forState:UIControlStateNormal];
    [self.view addSubview:gradeBtn];
    
}
///MARK:版本号
- (NSString *)appversion{

    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    return [NSString stringWithFormat:@"v%@", version];
}

///MARK:评分
- (void)appgrade{
    [UIApplication openReviewPageWithAppID:APP_ID];
}

///MARK:协议
- (void)appAgreement{
    
    PPUserAgreementViewController *vc = [[PPUserAgreementViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//
//    switch(indexPath.row) {
//        case 0: {
//           
//            break;
//        }
//
//        case 1: {
//
//        }
//    }
//}
@end
